define(function() {
    function setLocal(ops){
        // console.log(id,price)
       const goodsMsg= localStorage.getItem("goodsMsg") ? JSON.parse(localStorage.getItem("goodsMsg")):[];
       if(goodsMsg.length<1){
           goodsMsg.push(ops)
       }else{
           let i =0
           const onoff=goodsMsg.some((val,idx)=>{
               i =idx
               return val.id === ops.id
           })
           if(onoff){
               goodsMsg[i].num++
           }else{
               goodsMsg.push(ops)
           }
       }
    
       localStorage.setItem("goodsMsg",JSON.stringify(goodsMsg))
    }

    return setLocal
});